package jenkins_utils

import (
	"context"
	"fmt"
	"github.com/bndr/gojenkins"
	"net/http"
)

func getAllJobs() {
	client := &http.Client{}
	// 初始化Jenkins客户端
	jenkins := gojenkins.CreateJenkins(client, "http://your-jenkins-server/", "username", "password") // 或者使用API Token
	ctx := context.Background()
	// 获取所有作业的列表
	jobs, err := jenkins.GetAllJobNames(ctx)
	if err != nil {
		fmt.Println("Failed to get job list: %v", err)
	}

	// 打印作业名称
	for _, jobName := range jobs {
		fmt.Println(jobName)
	}
}
